package com.liao.product.controller;

import com.liao.common.entity.product.CommentEntity;
import com.liao.common.utils.PageUtils;
import com.liao.product.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 商品评价信息
 *
 * @author liao
 * @email 2858015963@qq.com
 * @date 2025-02-13 13:26:53
 */
@RestController
@RequestMapping("product/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public PageUtils<CommentEntity> list(@RequestParam Map<String, Object> params) {
        return commentService.queryPage(params);


    }


    /**
     * 信息
     */
    @RequestMapping("/info/{commentId}")
    public CommentEntity info(@PathVariable("commentId") Integer commentId) {
        return commentService.getById(commentId);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public void save(@RequestBody CommentEntity comment) {
        commentService.save(comment);

    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public void update(@RequestBody CommentEntity comment) {
        commentService.updateById(comment);

    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public void delete(@RequestBody Integer[] commentIds) {
        commentService.removeByIds(Arrays.asList(commentIds));

    }

}
